package com.xh.easyretry.common;


import com.xh.easyretry.visitor.RetryVisitor;
import com.xh.easyretry.visitor.Visitor;

public class XHRetryResult implements Element {

    private XHRetryContext retryContext;
    private Object result;
    private Integer currentRetryCountRecord;
    private Visitor visitor;

    public XHRetryResult(XHRetryContext retryContext, Object result) {
        this.retryContext = retryContext;
        this.result = result;
        this.visitor = RetryVisitor.getInstance();
    }

    public XHRetryResult(XHRetryContext retryContext, Object result, Integer currentRetryCountRecord) {
        this.retryContext = retryContext;
        this.result = result;
        this.currentRetryCountRecord = currentRetryCountRecord;
        this.visitor = RetryVisitor.getInstance();
    }

    public XHRetryContext getRetryContext() {
        return retryContext;
    }

    public void setRetryContext(XHRetryContext retryContext) {
        this.retryContext = retryContext;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    public Integer getCurrentRetryCountRecord() {
        return currentRetryCountRecord;
    }

    public void setCurrentRetryCountRecord(Integer currentRetryCountRecord) {
        this.currentRetryCountRecord = currentRetryCountRecord;
    }

    public Visitor getVisitor() {
        return visitor;
    }

    public void setVisitor(Visitor visitor) {
        this.visitor = visitor;
    }

    @Override
    public String toString() {
        return "XHRetryResult{" +
                "retryContext=" + retryContext +
                ", result=" + result +
                ", currentRetryCountRecord=" + currentRetryCountRecord +
                ", visitor=" + visitor +
                '}';
    }

    @Override
    public void accept() {
        visitor.visit(this);
    }

    @Override
    public void accept(Visitor visitor) {
        this.visitor = visitor;
        accept();
    }
}
